package com.bysj.service;

import com.bysj.dao.UserDao;
import com.bysj.entity.News;
import com.bysj.entity.User;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserDao userDao;
    @Override
    public void insertUser(User user) {
        userDao.insertUser(user);
    }

    @Override
    public List<User> getAll(Map map) {
        return userDao.getAll(map);
    }

    @Override
    public List<User> selectByOpenId(String openid) {
        return userDao.selectByOpenId(openid);
    }
    //根据id删除用户
    @Override
    public void deleteUserById(Integer id) {
        userDao.deleteUserById(id);
    }
    //根据id更新用户
    @Override
    public void updateUserInfoById(User user) {
        userDao.updateUserInfoById(user);
    }
    //分页查询所有用户
    @Override
    public PageInfo<User> getAllUserByPage(Map map, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> userList = userDao.getAll(map);
        PageInfo<User> pageInfo = new PageInfo<User>(userList);
        return pageInfo;
    }
}
